package com.ls.socketio.bean;

import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 酒店信息
 * @author liShan
 * @date 2019/9/3 11:19
 */
@Getter
@Setter
@ToString
@Entity(name = "hotel")
public class HotelInfo implements Serializable {

    @Id
    @Column(name = "hotel_id")
    private int hotelId;

    @Column(name = "hotel_name")
    private String hotelName;

    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
    @JoinColumn(name = "hotel_id")
    private List<BuildInfo> buildInfos;

    public HotelInfo() {
    }

    private HotelInfo(Builder builder){
        this.hotelId = builder.hotelId;
        this.hotelName = builder.hotelName;
        this.buildInfos = builder.buildInfos;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder{

        private int hotelId;
        private String hotelName;
        private List<BuildInfo> buildInfos;

        public Builder hotelId(int hotelId){
            this.hotelId = hotelId;
            return this;
        }

        public Builder hotelName(String hotelName){
            this.hotelName = hotelName;
            return this;
        }

        public Builder buildInfos(List<BuildInfo> buildInfos){
            this.buildInfos = buildInfos;
            return this;
        }

        public HotelInfo build() {
            return new HotelInfo(this);
        }

    }

}
